package com.sskj.mine.presenter;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.SPUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.SPConfig;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.util.EncodeUtils;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.SetLoginPwdActivity;


/**
 * @author Hey
 * Create at  2019/05/01
 */
public class SetLoginPwdPresenter extends BasePresenter<SetLoginPwdActivity> {


    //重置登录密码
    public void setLoginPwd(String newPwd, String oldPwd) {
        OkGo.<HttpData>post(HttpConfig.BASE_URL + (HttpConfig.SET_LOGIN_PWD))
                .params("id", SPUtil.get(SPConfig.ID, ""))
                .params("pswd", newPwd,true)
                .params("oldPswd", oldPwd,true)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpListData = response.body();
                        ToastUtil.showShort(httpListData.getMsg());
                        if (httpListData.getStatus() == 200) {
                            mView.updataUI();
                        }
                    }
                });
    }

}
